Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

objectdiff

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

objectdiff

Compares JavaScript objects

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5.6K
decreased by-8.04%
Maintainers
1
Weekly downloads
 
Created
Source

#objectDiff

objectdiff on npm

objectDiff.diff(objectA, objectB)

objectDiff.diff({x: 1}, {x: 2})
-> {
  changed: "object change",
  value: {
    x: {
      changed: "primitive change",
      removed: 1,
      added: 2
    }
  }
}

objectDiff.diff({z: {x: 1}}, {z: {y: 2}})
-> {
  changed: "object change",
  value: {
    z: {
      changed: "object change",
      value: {
        x: {
          changed: "removed",
          value: 1
        },
        y: {
          changed: "added",
          value: 2
        }
      }
    }
  }
}

objectDiff.diffOwnProperties(objectA, objectB)

Same as objectDiff.diff, but compares only objects' own properties

function A(){}
A.prototype.x = 1
objectDiff.diff({x: 1}, new A)
-> {changed: "equal", value: {x: 1}}

objectDiff.diffOwnProperties({x: 1}, new A)
-> {changed: "object change", value: {x: {changed: "removed", value: 1}}}

objectDiff.convertToXMLString(diffObject)

Used on the demo page.

Jasmine integration

objectDiff provides toEqualProperties and toEqualOwnProperties matchers for Jasmine. See example spec.

Keywords

FAQs

Package last updated on 20 Jun 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc